<include file="./Tpl/Home/top.html"/>
<include file="./Tpl/Home/header.html" />
<!--交易页面的子导航区-->
<div class="subnav">
      <div class="container">
            <ul>
                 <li class="cur"><a href="{$path}/Hall">买入 | 卖出</a><i></i></li>
				 <li><a href="{$path}/Hall/ent">我的委托</a><i></i></li>
				 <li><a href="{$path}/Hall/trans">我的交易</a></li>
				 <li><a href="{$path}/Hall/alltrans">全站交易</a></li>
            </ul>
      </div>    
</div>

<div class="container" style="margin-top:20px;">
    <!--信息公告-->
    <div class="markets">
	<div class="markets_tit">交易市场</div>
    <volist name="tb" id="vo">
	    <a href="{$path}/Hall/index/id/{$vo.id}">
		{$vo.goods}/{$vo.coin}
		<p style="text-align:center;<eq name='vo.ch' value='↑'>color:#ff0000;<else/>color:#07860E;</eq>">{$vo.price|default=0} {$vo.ch}</p>
		</a>
	</volist>
    </div>
      <!--行情区-->
      <div class="p_rel">
            <div class="o_h_z" id="realtime">
            </div>
      </div>
	  <script>
	  $(document).ready(function(){
	      $('#realtime').load('/?s=Home/Hall/chart/line/60/id/{$id}/goods/{$goods}/coin/{$coin}');
		  var sc = null;
		  clearInterval(sc);
		  var line = 60;
		  var goods = "{$goods}";
		  var coin = "{$coin}";
		  sc = setInterval(function(){
		      $('#realtime').load('/?s=Home/Hall/chart/line/'+line+'/id/{$id}/goods/'+goods+'/coin/'+coin);
		  },360000);
	  });
	  </script>
      <div class="trade-part-all">
            <!--左边栏-->
            <div class="part-l">
				<!--[if IE]>
				<style>
				.trade-all-form{ height:410px;}
				</style>
				<![endif]--> 

                 <!--交易买卖平台-->
                 <div class="trade-all-form">
                       <div class="hd">
                             <span class="active" name="buy"><b class="tx-red">买入</b></span>
                             <span name="sell"><b class="tx-green">卖出</b></span>
                             <div class="clear"></div>
                       </div>
                       <!--交易买卖平台内容区-->
                       <div class="md">
                           <!--买入买出表单-->
                           
                           <div class="form_add_btc">
                               <div id="buy" class="tf-form">
                               <form class="form-horizontal" id="tf1" action="{$path}/GuaDan/work" method="post">
							   <input type="hidden" name="flag" value="1"/>
				               <input type="hidden" name="typeboxid" value="{$id}"/>
							   <div class="tf">
									<div class="tf-input">
							            <div class="tf-line">
											<span>买入价</span><input name="price" value="{$minout|default=0}" type="text"/>
										</div>
									    <div class="tf-line">
										    <span>购买数量</span><input name="num" value="0" type="text"/>
                                        </div> 
										<div class="tf-line">
											<span>总额</span><input name="total" readonly value="0" type="text"/>
										</div>
										<div class="tf-line">
											<span>交易密码</span><input name="transpw" type="password"/>
										</div>
									</div>
									<div class="tf-text">
										<div class="tf-line">
                                          <input type="button" value="买入" id="buy_btn" class="tf-btn"/>
										</div>
										<div class="tf-info">
                                            <p>建议价格<span class="red">{$minout|default=0}</span>{$coin}</p>
                                            <p>最多可买<span class="red">{$ablenumout|default=0}</span>{$goods}</p>
                                        </div>
									</div>
									<div class="clear"></div>
					           </div>
                               </form>
				               </div>
                              <script language="javascript">
                              function ckNum(n){
							      if(n=='' || isNaN(n) || n <= 0){
								     return false;
								  }else{
								     return true;
								  }
							  }

							  $(document).ready(function(){
								  $('#tf1 input[name=price],#tf1 input[name=num]').bind('keyup change',function(){
								      var price = $('#tf1 input[name=price]').val();
									  var num = $('#tf1 input[name=num]').val();

									  if(price=="" || isNaN(price)){
										  $('#tf1 input[name=price]').val(0);
										  msgDalog("价格应为数字！","",0);
										  return false;
								      }

                                      if(num=="" || isNaN(num)){
										  $('#tf1 input[name=num]').val(0);
										  msgDalog("数量应为数字！","",0);
										  return false;
									  }

									  var pos = price.indexOf('.');
									  if(pos != -1){
											if(price.substring(0,pos)=='') {
												msgDalog('价格不合法！',"",0);
												$('#tf1 input[name=price]').val(0);
												$('#tf1 input[name=price]').focus();
												return false;
											}
											len = price.substring(pos+1,price.length);
											if(len.length > 6) {
												v = price.substring(0,pos) + '.' + price.substring(pos+1,pos+7);
												$('#tf1 input[name=price]').val(v);
												price = v;
											}
									  }
									  var pos = num.indexOf('.');
									  if(pos != -1){
											if(num.substring(0,pos)=='') {
												msgDalog('价格不合法！',"",0);
												$('#tf1 input[name=num]').val(0);
												$('#tf1 input[name=num]').focus();
												return false;
											}
											len = num.substring(pos+1,num.length);
											if(len.length > 6) {
												v = num.substring(0,pos) + '.' + num.substring(pos+1,pos+7);
												$('#tf1 input[name=num]').val(v);
												num = v;
											}
									  }

									  var price = parseFloat(price);
									  var num = parseFloat(num);
									  var total = price * num;

                                      total = String(total);
									  var pos = total.indexOf('.');
									  if(pos != -1){
											if(total.substring(0,pos)=='') {
												msgDalog('总额不合法！',"",0);
												$('#tf1 input[name=total]').val(0);
												return false;
											}
											len = total.substring(pos+1,total.length);
											if(len.length > 6) {
												v = total.substring(0,pos) + '.' + total.substring(pos+1,pos+7);
												$('#tf1 input[name=total]').val(v);
												total = v;
											}
									  }

									  var balance = {$buy_remain|default=0};
									  if(total > balance){
									      msgDalog('您的余额不够！',"",0);
                                          $('#tf1 input[name=price]').val(0);
										  $('#tf1 input[name=num]').val(0);
										  $('#tf1 input[name=total]').val(0);
										  return false;
									  }

									  $('#tf1 input[name=total]').val(total);
								  });

								  $('#buy_btn').click(function(){

                                      <if condition="$buyflag neq 1">
                                           msgDalog("还未开盘，不能购买！","",0);
                                      return;
                                      </if>

									  var o_price = $('#tf1 input[name=price]');
									  var o_num = $('#tf1 input[name=num]');
									  var o_total = $('#tf1 input[name=total]');
									  var o_transpw = $('#tf1 input[name=transpw]');

								      if(o_price.val()==""||o_price.val()<=0||isNaN(o_price.val())){
									      msgDalog("请输入价格！","",0);
									  }else if(o_num.val()==""||o_num.val()<=0||isNaN(o_num.val())){
									      msgDalog("请输入数量！","",0);
									  }else if(o_total.val()==""||o_total.val()<=0||isNaN(o_total.val())){
									      msgDalog("总额要大于0！","",0);
									  }else if(o_transpw.val()==""){
									      msgDalog("交易密码不能为空！","",0);
									  }else{
									      $('#tf1').submit();
									  }
								  });
							  });
							  </script>
                               <div style="display:none;" id="sell" class="tf-form">
                               <form class="form-horizontal" id="tf2" action="{$path}/GuaDan/work" method="post">
							   <input type="hidden" name="flag" value="0">
				               <input type="hidden" name="typeboxid" value="{$id}">
							   <div class="tf">
									<div class="tf-input">
							            <div class="tf-line">
											<span>卖出价</span><input name="price" value="{$maxin|default=0}" type="text"/>
										</div>
									    <div class="tf-line">
										    <span>卖出数量</span><input name="num" value="0" type="text"/>
                                        </div>
										<div class="tf-line">
											<span>总额</span><input name="total" readonly value="0" type="text"/>
										</div>
										<div class="tf-line">
											<span>交易密码</span><input name="transpw" type="password"/>
										</div>
									</div>
									<div class="tf-text">
										<div class="tf-line">
                                          <input type="button" value="卖出" id="sell_btn" class="tf-btn"/>
										</div>
										<div class="tf-info">
                                            <p>建议价格<span class="red">{$maxin|default=0}</span>{$coin}</p>
                                            <p>最多可卖<span class="red">{$sell_remain|default=0}</span>{$goods}</p>
                                        </div>
									</div>
									<div class="clear"></div>
					           </div>
                               </form>
							   </div>

							   <script language="javascript">
							  $(document).ready(function(){
								  $('#tf2 input[name=price],#tf2 input[name=num]').bind('keyup change',function(){
								      var price = $('#tf2 input[name=price]').val();
									  var num = $('#tf2 input[name=num]').val();

									  if(price=="" || isNaN(price)){
										  $('#tf2 input[name=price]').val(0);
										  msgDalog("价格应为数字！","",0);
										  return false;
								      }

                                      if(num=="" || isNaN(num)){
										  $('#tf2 input[name=num]').val(0);
										  msgDalog("数量应为数字！","",0);
										  return false;
									  }

									  var pos = price.indexOf('.');
									  if(pos != -1){
											if(price.substring(0,pos)=='') {
												msgDalog('价格不合法！',"",0);
												$('#tf2 input[name=price]').val(0);
												$('#tf2 input[name=price]').focus();
												return false;
											}
											len = price.substring(pos+1,price.length);
											if(len.length > 6) {
												v = price.substring(0,pos) + '.' + price.substring(pos+1,pos+7);
												$('#tf2 input[name=price]').val(v);
												price = v;
											}
									  }
									  var pos = num.indexOf('.');
									  if(pos != -1){
											if(num.substring(0,pos)=='') {
												msgDalog('价格不合法！',"",0);
												$('#tf2 input[name=num]').val(0);
												$('#tf2 input[name=num]').focus();
												return false;
											}
											len = num.substring(pos+1,num.length);
											if(len.length > 6) {
												v = num.substring(0,pos) + '.' + num.substring(pos+1,pos+7);
												$('#tf2 input[name=num]').val(v);
												num = v;
											}
									  }

									  var price = parseFloat(price);
									  var num = parseFloat(num);
									  var total = price * num;

                                      total = String(total);
									  var pos = total.indexOf('.');
									  if(pos != -1){
											if(total.substring(0,pos)=='') {
												msgDalog('总额不合法！',"",0);
												$('#tf2 input[name=total]').val(0);
												return false;
											}
											len = total.substring(pos+1,total.length);
											if(len.length > 6) {
												v = total.substring(0,pos) + '.' + total.substring(pos+1,pos+7);
												$('#tf2 input[name=total]').val(v);
												total = v;
											}
									  }

                                      var balance = {$sell_remain|default=0};
									  if(num > balance){
									      msgDalog('您的余额不够！',"",0);
                                          $('#tf2 input[name=price]').val(0);
										  $('#tf2 input[name=num]').val(0);
										  $('#tf2 input[name=total]').val(0);
										  return false;
									  }

									  $('#tf2 input[name=total]').val(total);
								  });

								  $('#sell_btn').click(function(){

                                      <if condition="$saleflag neq 1">
                                              msgDalog("暂不能卖出！","",0);
                                      return;
                                      </if>


									  var o_price = $('#tf2 input[name=price]');
									  var o_num = $('#tf2 input[name=num]');
									  var o_total = $('#tf2 input[name=total]');
									  var o_transpw = $('#tf2 input[name=transpw]');

								      if(o_price.val()==""||o_price.val()<=0||isNaN(o_price.val())){
									      msgDalog("请输入价格！","",0);
									  }else if(o_num.val()==""||o_num.val()<=0||isNaN(o_num.val())){
									      msgDalog("请输入数量！","",0);
									  }else if(o_total.val()==""||o_total.val()<=0||isNaN(o_total.val())){
									      msgDalog("总额要大于0！","",0);
									  }else if(o_transpw.val()==""){
									      msgDalog("交易密码不能为空！","",0);
									  }else{
									      $('#tf2').submit();
									  }
								  });
							  });
							  </script>

                               </div>   
                     
                      </div>

					  <script language="javascript">
					  $(document).ready(function(){
					      $('.hd span').click(function(){
						      $('.tf-form').hide();
							  $('#'+$(this).attr('name')).show();

							  $('.hd span').removeClass('active');
							  $(this).addClass('active');

                              $('.weituo').hide();
                              $('#'+$(this).attr('name')+'list').show();
						  });

						  $('input[name=price],input[name=num]').focus(function(){
						      if($(this).val()==0) $(this).val('');
						  });
						  $('input[name=price],input[name=num]').blur(function(){
						      if($(this).val()=='') $(this).val(0);
						  });
					  });
					  </script>

                      <div class="asset">
                           <div>
                                <dl>
                                    <dt>可用{$goods}</dt>
                                    <dd><span class="font-wei"></span><span id="RMB_pure_balance">{$sell_remain|default=0}</span></dd>
                                </dl>
                                <dl>
                                    <dt>冻结{$goods}</dt>
                                    <dd><span id="RMB_frozen" class="RMB_frozen">{$sell_gdgold|default=0}</span></dd>
                                </dl>
                                <dl>
                                    <dt>可用{$coin}</dt>
                                    <dd><span id="BTC_pure_balance">{$buy_remain|default=0}</span></dd>
                                </dl>
                                <dl style="border-right:0px none;">
                                    <dt>冻结{$coin}</dt>
                                    <dd><span id="BTC_frozen" class="BTC_frozen">{$buy_gdgold|default=0}</span></dd>
                                </dl>
                           </div>
                      </div>
                      <div class="clear"></div>
                 </div>
            </div>
            <!--右边栏-->
            <div class="part-r">
                 <!--贸易区-->
                 <div class="trade-all trade-form-box">
                     <!--买卖委托盘-->
                     <div class="trade-part-hd part-business weituo" id="buylist">
                           <div class="trade-hd">
                                 <h6><i class="icon_entrus"></i>卖出委托盘</h6>
                           </div>
                           <div class="md">
							 <table width="100%">
								  <thead>
									   <tr>
										   <th>类型</th>
										   <th>价格<font face="微软雅黑"></font></th>
										   <th>数量</th>
									  </tr>
								  </thead>
								  <tbody>
								  <volist name="sells" id="vo" key="k" empty="$empty">
								  <tr>
									  <td class="sell">卖</td>
									  <td><span class="sub_price">{$vo.price}</span></td>
									  <td><span class="sub_amount">{$vo.nums}</span></td>
									  <td><span style="width:0.065px" class="buySpan"></span></td>
								  </tr>
								  </volist>
								  </tbody>
							 </table> 
							 
                           </div>
                     </div>
					 <div class="trade-part-hd part-business weituo" id="selllist" style="display:none;">
                           <div class="trade-hd">
                                 <h6><i class="icon_entrus"></i>买入委托盘</h6>
                           </div>
                           <div class="md">
							 <table width="100%">
								  <thead>
									   <tr>
										   <th>类型</th>
										   <th>价格<font face="微软雅黑"></font></th>
										   <th>数量</th>
									  </tr>
								  </thead>
								  <tbody>
								  <volist name="buys" id="vo" key="k" empty="$empty">
								  <tr>
									  <td class="buy">买</td>
									  <td><span class="sub_price">{$vo.price}</span></td>
									  <td><span class="sub_amount">{$vo.nums}</span></td>
									  <td><span style="width:0.596px" class="sellSpan"></span></td>
								  </tr>
								  </volist>
								  </tbody>
							 </table>
                           </div>
                     </div>
                 </div>
            </div>
      </div>
      <div class="o_h_z">
           <div class="part-l" style="width:100%;">
		        <div class="trade-part trade-part-hd mt20">
					<table style="width:475px;float:left;">
						  <thead>
						      <tr><td colspan=3><b>买入委托</b></td></tr>
							  <tr>
								   <th>类型</th>
								   <th>价格<font face="微软雅黑"></font></th>
								   <th>数量</th>
							  </tr>
						  </thead>
						  <tbody>
						  <volist name="buys" id="vo" key="k" empty="$empty">
						  <tr>
							  <td class="buy">买</td>
							  <td><span class="sub_price">{$vo.price}</span></td>
							  <td><span class="sub_amount">{$vo.nums}</span></td>
						  </tr>
						  </volist>
						  </tbody>
					</table>
					<table style="width:475px;float:left;margin-left:50px;">
						  <thead>
						       <tr><td colspan=3><b>卖出委托</b></td></tr>
							   <tr>
								   <th>类型</th>
								   <th>价格<font face="微软雅黑"></font></th>
								   <th>数量</th>
							  </tr>
						  </thead>
						  <tbody>
						  <volist name="sells" id="vo" key="k" empty="$empty">
						  <tr>
							  <td class="sell">卖</td>
							  <td><span class="sub_price">{$vo.price}</span></td>
							  <td><span class="sub_amount">{$vo.nums}</span></td>
						  </tr>
						  </volist>
						  </tbody>
					 </table> 
					 <div style="clear:both"></div>
                </div>
				<!--交易记录-->
                <div class="trade-part trade-part-hd mt20">
                  <div class="trade-hd">
                        <h5>
                             <i class="icon_condition"></i>交易记录</h5>
                        <p><a href="{$path}/Hall/alltrans">查看更多&nbsp;&gt;</a></p>
                  </div>
                  <div class="md">
                  <div class="my-grid" id="order-grid-transaction">
					<table class="items table table-striped table-bordered table-condensed">
					<thead>
					<tr>
					<th>创建时间</th><th>交易类型</th><th>价格</th><th>数量</th><th>总金额</th></tr>
					</thead>
					<tbody>
					<volist name="translogs" id="vo" empty="$translog_emp">
					<tr><td>{$vo.addtime|default='无'}</td><td><eq name="vo.flag" value="0">卖<else/>买</eq></td><td>{$vo.price|default=0}</td><td>{$vo.num|default=0}</td><td>{$vo.sum|default=0}</td></tr>
					</volist>
					</tbody>
					</table>
					</div>
                   </div>
                </div>

				<!--我的委托-->
                <div class="trade-part trade-part-hd mt20">
                  <div class="trade-hd">
                      <h5><i class="icon_userde"></i>我的委托</h5>
                      <p><a href="{$path}/Hall/ent">查看更多&nbsp;&gt;</a></p>
                  </div>
                  <div class="md">
                  <div class="my-grid" id="order-grid">
					<table class="items table table-striped table-bordered table-condensed">
					<thead>
					<tr>
					<th>创建时间</th><th>交易类型</th><th>数量</th><th>价格</th><th>操作</th></tr>
					</thead>
					<tbody>
					<volist name="myent" id="vo" empty="$ent_emp">
					<tr><td>{$vo.addtime|default='无'}</td><td><eq name="vo.flag" value="0">卖<else/>买</eq></td><td>{$vo.num|default=0}</td><td>{$vo.price|default=0}</td><td><a href="{$path}/GuaDan/cancel/id/{$vo.id}">取消委托</eq></td></tr>
					</volist>
					</tbody>
					</table>
					</div>
                  </div>
                </div>
                
                <!--我的交易记录-->
                <div class="trade-part trade-part-hd mt20">
                  <div class="trade-hd">
                        <h5>
                             <i class="icon_condition"></i>我的交易</h5>
                        <p><a href="{$path}/Hall/trans">查看更多&nbsp;&gt;</a></p>
                  </div>
                  <div class="md">
                  <div class="my-grid" id="order-grid-transaction">
					<table class="items table table-striped table-bordered table-condensed">
					<thead>
					<tr>
					<th>创建时间</th><th>交易类型</th><th>价格</th><th>数量</th><th>总金额</th></tr>
					</thead>
					<tbody>
					<volist name="mytrans" id="vo" empty="$trans_emp">
					<tr><td>{$vo.addtime|default='无'}</td><td><eq name="vo.flag" value="0">卖<else/>买</eq></td><td>{$vo.price|default=0}</td><td>{$vo.num|default=0}</td><td>{$vo.sum|default=0}</td></tr>
					</volist>
					</tbody>
					</table>
					</div>
                   </div>
                </div>
            </div>
      </div>
</div>

<!--尾部-->
<include file="./Tpl/Home/footer.html" />
  <!-- footer -->

<!--[if IE 6]><script src="/js/ie-6.js"></script><![endif]-->
<script type="text/javascript" src="/Public/Home/js/jquery.SuperSlide.js"></script>
<script type="text/javascript" src="/Public/Home/js/slideTxtBox.js"></script>
<script type="text/javascript" src="/Public/Home/js/bootbox.js"></script>
<script type="text/javascript" src="/Public/Home/js/box.js"></script>
<script type="text/javascript" src="/Public/Home/js/lang(1).js"></script>
<script type="text/javascript" src="/Public/Home/js/responseHandler.js"></script>
<script type="text/javascript" src="/Public/Home/js/jquery.yiigridview.js"></script>
</body>
</html>